#include "OSMNode.h"

OSMNode::OSMNode()
{

}

unsigned int OSMNode::getId()
{
    return m_id;
}

void OSMNode::setId(unsigned int id)
{
    m_id = id;
}

void OSMNode::setLatitude(float lat)
{
    m_latitude = lat;
}

void OSMNode::setLongitude(float lon)
{
    m_longitude = lon;
}

float OSMNode::getLatitude()
{
    return m_latitude;
}

float OSMNode::getLongitude()
{
    return m_longitude;
}

const QMap<QString, QString>* OSMNode::getFeatures()
{
    return &m_features;
}

void OSMNode::addFeature(const QString& key, const QString& value)
{
    m_features.insert(key, value);
}

bool OSMNode::isMarina(QString& category, QString& name)
{
    QString categoryKey("leisure");
    QString nameKey("seamark:name");

    if(!m_features.contains(categoryKey) || m_features.value(categoryKey) != "marina")
    {
        return false;
    }

    name = m_features.value(nameKey);
    category = "marina";

    return true;
}

bool OSMNode::isRestaurant(QString& category, QString& name)
{
    QString categoryKey("amenity");
    QString nameKey("name");

    if(!m_features.contains(categoryKey) || m_features.value(categoryKey) != "restaurant")
    {
        return false;
    }

    category = m_features.value(categoryKey);
    
    if(m_features.contains(nameKey))
    {
        name = m_features.value(nameKey);
    }

    return true;
}